package cn.edu.neu.controller;

import cn.edu.neu.model.ScenicSpot;
import cn.edu.neu.service.ScenicSpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class HomeController {

    @Autowired
    private ScenicSpotService scenicSpotService;

    @GetMapping(value = "/")
    public String home() {
        return "redirect:/index";
    }

    @RequestMapping(value = "/index")
    public String toIndex(Model model) {
        List<ScenicSpot> scenicSpots = scenicSpotService.getScenicSpotList();
        model.addAttribute("scenicspots", scenicSpots);
        return "/homepage/index";
    }
}
